<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Hello, this is browser ui.</title>
</head>
<body>
<h2>UI - Home</h2>
<p>This is browser ui. Please start demo or test from here.</p>

<div>
    <div>请点击下面的按钮，读取用户信息。</div>
    <div>
        <button id="btn_read_user_info_api">获取用户信息</button>
    </div>
</div>

<ol>
    <li><a href="http://user.pphh.com:9000/user/login.html?callback=http%3a%2f%2fui.pphh.com%3a9000%2fui">User Login</a>
    </li>
    <li><a href="http://user.pphh.com:9000/user/logout.html">User Logout</a></li>
    <li><a href="http://user.pphh.com:9000/user">Go User Home</a></li>
</ol>
</body>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">

    $("#btn_read_user_info_api").click(function () {

        $.ajax({
            url: "/ui/api/user",
            type: "GET",
            contentType: "application/json;charset=utf-8",
            success: function (data, status, ajax) {
                console.log("success to read user info.");
                if (data == null || data.userName == null || data.userName == "" || data.userRole == null || data.userRole == "") {
                    alert("用户未登录，请先进行登录。");
                } else {
                    alert("用户已登录，用户名为：" + data.userName + "用户角色为：" + data.userRole);
                }
            },
            error: function (ajax, status, error) {
                console.log("fail to read user info.");
                alert("获取用户信息失败");
            }
        });

    });

</script>
</html>